<?php
/**
 * Created by PhpStorm.
 * User: dddd
 * Date: 2017/12/29
 * Time: 下午2:32
 */
class Api_BackConsult extends PhalApi_Api
{
    public function getRules()
    {
        return array(
            'insertConsultAuthor' => [
                'consultAuthorName' => ['name' => 'consultAuthorName', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '作者姓名'],
                'bindUser' => ['name' => 'bindUser', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => '预留'],
            ],
            'deleteConsultAuthor' => [
                'id' => ['name' => 'id','type' => 'int', 'require' => true, 'desc' => '作者id'],
            ],

            'updateConsult' => [
                'id' => ['name' => 'id','type' => 'int', 'require' => true, 'desc' => '咨询id'],
                'consultName' => ['name' => 'consultName', 'type' => 'string', 'min' => 1,'max' => 50, 'require' => true, 'desc' => '咨询名称'],
                'consultImg' => ['name' => 'consultImg', 'type' => 'string',  'min' => 1,'max' => 150,'require' => true, 'desc' => '咨询图片链接'],
                'video' => ['name' => 'video', 'type' => 'string',  'min' => 1,'max' => 150,'require' => true, 'desc' => '视频链接'],
                'consultDetail' => ['name' => 'consultDetail', 'type' => 'string','require' => true, 'desc' => '咨询内容'],
                'top' => ['name' => 'top', 'type' => 'int','require' => true, 'desc' => '置顶顺序 默认1'],
                'classId' => ['name' => 'classId', 'type' => 'int', 'require' => true, 'desc' => '分类id'],
                'authorId' => ['name' => 'authorId', 'type' => 'int', 'require' => true, 'desc' => '作者id'],
                'recommendID' => ['name' => 'recommendID', 'type' => 'int', 'require' => true, 'desc' => '推荐模板id'],
                'hot'=>['name'=>'hot','type'=>'int', 'require' => false,'desc'=>'是否热门 0不是 1是']
            ],

            'insertConsult' => [
                'consultName' => ['name' => 'consultName', 'type' => 'string', 'min' => 1,'max' => 50, 'require' => true, 'desc' => '咨询名称'],
                'consultImg' => ['name' => 'consultImg', 'type' => 'string',  'min' => 1,'max' => 150,'require' => true, 'desc' => '咨询图片链接'],
                'video' => ['name' => 'video', 'type' => 'string',  'min' => 1,'max' => 150,'require' => true, 'desc' => '视频链接'],
                'consultDetail' => ['name' => 'consultDetail', 'type' => 'string','require' => true, 'desc' => '咨询内容'],
                'top' => ['name' => 'top', 'type' => 'int','require' => true, 'desc' => '置顶顺序 默认1'],
                'classId' => ['name' => 'classId', 'type' => 'int', 'require' => true, 'desc' => '分类id'],
                'authorId' => ['name' => 'authorId', 'type' => 'int', 'require' => true, 'desc' => '作者id'],
                'recommendID' => ['name' => 'recommendID', 'type' => 'int', 'require' => true, 'desc' => '推荐模板id'],
                'hot'=>['name'=>'hot','type'=>'int', 'require' => false,'desc'=>'是否热门 0不是 1是']
            ],
            'insertRecommend' => [
                'id1' => ['name' => 'id1', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id 1号'],
                'type1' => ['name' => 'type1', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
                'id2' => ['name' => 'id2', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id'],
                'type2' => ['name' => 'type2', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
                'id3' => ['name' => 'id3', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id'],
                'type3' => ['name' => 'type3', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
            ],
            'deleteRecommend' => [
                'id' => ['name' => 'id','type' => 'int', 'require' => true, 'desc' => '模板id'],
            ],
            'updateRecommend' => [
                'id' => ['name' => 'id', 'min' => 1,'max' => 20,'type' => 'int', 'require' => true, 'desc' => '模板id'],
                'id1' => ['name' => 'id1', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id 1号'],
                'type1' => ['name' => 'type1', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
                'id2' => ['name' => 'id2', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id'],
                'type2' => ['name' => 'type2', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
                'id3' => ['name' => 'id3', 'min' => 1,'max' => 20,'type' => 'string', 'require' => true, 'desc' => '文章id'],
                'type4' => ['name' => 'type3', 'type' => 'string', 'min' => 1,'max' => 20,'require' => false, 'desc' => 'type 1咨询 2视频 3快讯'],
            ],
            'userList' => [
                'nickName' => ['name' => 'nickName', 'type' => 'string', 'min' => 1,'max' => 50, 'require' => false, 'desc' => '用户昵称'],
                'fid' => ['name' => 'fid','type' => 'int', 'require' => false, 'desc' => '直属下级'],
                'pid' => ['name' => 'pid','type' => 'int', 'require' => false, 'desc' => '下级代理'],
                'level' =>  ['name' => 'level','type' => 'int', 'require' => false, 'desc' => '用户等级'],
                'id' => ['name' => 'id','type' => 'int', 'require' => false, 'desc' => '用户id'],
                'page' => ['name' => 'page','type' => 'int', 'require' => true, 'desc' => '页码']
            ],
            'updateUserLevel' => [
                'id' => ['name' => 'id','type' => 'int', 'require' => false, 'desc' => '要修改的用户id'],
                'level' =>  ['name' => 'level','type' => 'int', 'require' => false, 'desc' => '用户等级']
            ],
            'userWallet' => [
            ],
            'userMoneyLog' => [
                'id' => ['name' => 'id','type' => 'int', 'require' => false, 'desc' => '用户id'],
                'page' => ['name' => 'page','type' => 'int', 'require' => true, 'desc' => '页码']
            ],
        );
    }

    /**
     * 新建咨询作者
     * @desc wjp 2017-12-27
     * @throws PhalApi_Exception_InternalServerError
     */
    public function insertConsultAuthor(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> insertConsultAuthor($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 删除咨询作者
     * @desc wjp 2017-12-27
     * @throws PhalApi_Exception_InternalServerError
     */
    public function deleteConsultAuthor(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> deleteConsultAuthor($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 新建推荐模板
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function insertRecommend(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> insertRecommend($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 删除推荐模板
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function deleteRecommend(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> deleteRecommend($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 推荐模板修改
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function updateRecommend(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> updateRecommend($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 咨询修改
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function updateConsult(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> updateConsult($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 新建咨询
     * @desc wjp 2017-1-4
     * @throws PhalApi_Exception_InternalServerError
     */
    public function insertConsult(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeConsult();
        $userInfo = $domain -> insertConsult($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $userInfo;
        return $userInfo;
    }

    /**
     * 代理列表
     * @return mixed
     */
    public function userList(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeData();
        $info = $domain -> userList($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $info;
        return $ret;
    }

    /**
     * 修改代理等级
     */
    public function updateUserLevel(){
        $allParams = $this -> allParams();
        if($allParams['level'] > 3){
            return DI()->ResCode->get("WE.Error");
        }
        $domain = new Domain_WeData();
        $info = $domain -> updateUserLevel($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $info;
        return $ret;
    }

    /**
     * 用户返利
     * @return mixed
     */
    public function userMoneyLog(){
        $allParams = $this -> allParams();
        $domain = new Domain_WeData();
        $info = $domain -> moneyLogList($allParams);
        $ret = DI()->ResCode->get("WE.Success");
        $ret['data'] = $info;
        return $ret;
    }
}